package com.rimi.mapper;

import com.rimi.model.dto.OrderGoodsDto;
import com.rimi.model.vo.PaymentVo;
import com.rimi.model.vo.RefundVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

@Mapper
public interface OrderMapper {
    /**
     * 根据商品id查商品价格
     * @param goodId 商品id
     * @return
     */
    double findPriceByGoodId(Integer goodId);

    int addOrder(Integer userId, String orderNo, Integer goodId, Integer goodQuantity, double totalPrice, String currentTime);

    List<OrderGoodsDto> findOrderGoodsByUserId(@Param("userId") Integer userId, @Param("function") String function);
    /**
     * 根据订单id查询订单
     * @param orderId
     * @return
     */
    PaymentVo findOrderByOrderId(Integer orderId,Integer userId);

    /**
     * 支付成功修改订单状态
     * @param orderNum
     * @param tradeNo
     * @param paymentTime
     * @param paymentPrice
     * @return
     */
    int paid(String orderNum, String tradeNo, Date paymentTime, Double paymentPrice,String defaultAddressInfo);

    /**
     * 根据退款订单id查询订单
     * @param orderId
     * @return
     */
    RefundVo findOrderRefundByOrderId(Integer orderId,Integer userId);
    /**
     * 修改订单退款状态为退款中，并修改退款类型，金额，原因，图片
     * @param refundVo
     * @return
     */
    int updateRefundOrderStatusForDuring(RefundVo refundVo);
    /**
     * 修改订单退款状态为退款成功
     * @param refundVo
     * @return
     */
    int updateRefundOrderStatusForSuccess(RefundVo refundVo);

    int received(Integer orderId);

    int cancelOrder(Integer orderId);

    int evaluated(Integer orderId);

    /**
     * 修改订单退款状态为退款失败
     * @param refundVo
     * @return
     */
    int updateRefundOrderStatusForFail(RefundVo refundVo);
}
